/**
 * For development test
 */

import { NamespacedLogger } from '@deepstream/types';
import { OBSSyncOptions } from './obs-sync';
import HuaweiCloudPlugin, { HuaweiCloudPluginOptions } from './plugin';
/**
 * Copy credentials.local.ts.sample to credentials.local.ts, and input your Huawei Cloud AK/SK.
 */
import credentials from './credentials.local';

const obsSyncOptions: OBSSyncOptions = {
    syncDir: '../heap-snapshots',
    bucketName: 'deepstream-sync-files',
    obsEndpoint: 'https://obs.cn-south-1.myhuaweicloud.com',
    // obsKeyPrefix: 'obsKeyPrefix',
};

const huaweiCloudPlugin: HuaweiCloudPluginOptions = {
    ...credentials,
    services: [{
        type: 'obs-sync',
        options: obsSyncOptions,
    }],
};

const logger: NamespacedLogger = {
    debug(event: string, message?: string | undefined, metaData?: any): void { console.log(message, metaData); },
    error(event: string, message?: string | undefined, metaData?: any): void { console.log(message, metaData); },
    fatal(event: string, message?: string | undefined, metaData?: any): void { console.log(message, metaData); },
    info(event: string, message?: string | undefined, metaData?: any): void { console.log(message, metaData); },
    shouldLog(logLevel: any) { return true; },
    warn(event: string, message?: string | undefined, metaData?: any): void { console.log(message, metaData); },
};

const pretendService = { logger: { getNameSpace(s: string) { return logger; } } } as any;
// eslint-disable-next-line no-new
const obsSync = new HuaweiCloudPlugin(huaweiCloudPlugin, pretendService);
obsSync.init();
obsSync.whenReady();
